#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> div(vector<int>&a,int &b){
  vector<int> c;
  int t=0;
  for(int i=a.size()-1;i>=0;i--){
    t=t*10+a[i];
    c.push_back(t/b);
    t%=b;
  }
  reverse(c.begin(),c.end());
  while(c.size()>1&&c.back()==0) c.pop_back();
  c.push_back(t);
  return c;
}
int main(){
  string A;
  int b;
  vector<int>a;
  cin>>A>>b;
  for(int i=A.size()-1;i>=0;i--) a.push_back(A[i]-'0');
  auto c = div(a,b);
  for(int i=c.size()-2;i>=0;i--) cout<<c[i];
  cout<<endl;
  cout<<c.back();
}